<script setup>
import { ref } from 'vue'

const currentProject = ref({
  name: '城市地铁规划 2024',
  lastModified: '2024-02-22 15:30',
  lines: [
    {
      id: 1,
      name: '1号线',
      color: '#E6002D',
      stations: 12,
      length: 23.5,
      status: 'active'
    },
    {
      id: 2,
      name: '2号线',
      color: '#009BC9',
      stations: 15,
      length: 27.8,
      status: 'construction'
    }
  ]
})

const tools = ref([
  { id: 'line', name: '绘制线路', icon: '📏' },
  { id: 'station', name: '添加站点', icon: '🚉' },
  { id: 'transfer', name: '换乘设置', icon: '🔄' },
  { id: 'edit', name: '编辑工具', icon: '✏️' }
])

const selectedTool = ref(tools.value[0])

const mapSettings = ref({
  zoom: 100,
  showGrid: true,
  showLabels: true,
  showTraffic: false
})

const projectStats = ref({
  totalLines: 5,
  totalStations: 42,
  totalLength: 89.6,
  dailyPassengers: 158000
})

const saveProject = () => {
  // 保存项目逻辑
}
</script>

<template>
  <div class="design-container">
    <div class="main-workspace">
      <div class="map-section">
        <div class="map-header">
          <div class="project-info">
            <h2>{{ currentProject.name }}</h2>
            <span class="last-modified">最后修改: {{ currentProject.lastModified }}</span>
          </div>
          <div class="map-controls">
            <button class="control-btn" @click="saveProject">保存项目</button>
            <button class="control-btn">导出地图</button>
          </div>
        </div>
        
        <div class="map-container">
          <!-- 地图绘制区域 -->
          <div class="map-canvas">
            <div class="placeholder-grid">
              <!-- 这里实际项目中会是真实的地图和线路 -->
              <div class="grid-overlay"></div>
            </div>
          </div>
          
          <div class="map-tools">
            <button 
              v-for="tool in tools"
              :key="tool.id"
              class="tool-btn"
              :class="{ active: selectedTool.id === tool.id }"
              @click="selectedTool = tool"
            >
              <span class="tool-icon">{{ tool.icon }}</span>
              <span class="tool-name">{{ tool.name }}</span>
            </button>
          </div>
        </div>
      </div>

      <div class="line-manager">
        <h3>线路管理</h3>
        <div class="lines-list">
          <div 
            v-for="line in currentProject.lines"
            :key="line.id"
            class="line-item"
          >
            <div class="line-color" :style="{ backgroundColor: line.color }"></div>
            <div class="line-info">
              <h4>{{ line.name }}</h4>
              <div class="line-stats">
                <span>{{ line.stations }}站</span>
                <span>{{ line.length }}km</span>
                <span :class="['line-status', line.status]">
                  {{ line.status === 'active' ? '运营中' : '建设中' }}
                </span>
              </div>
            </div>
            <div class="line-actions">
              <button class="action-btn">编辑</button>
              <button class="action-btn">详情</button>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="side-panel">
      <div class="map-settings">
        <h3>地图设置</h3>
        <div class="settings-list">
          <div class="setting-item">
            <label>缩放比例</label>
            <input 
              type="range" 
              v-model="mapSettings.zoom" 
              min="50" 
              max="200"
            >
            <span class="setting-value">{{ mapSettings.zoom }}%</span>
          </div>
          <div class="setting-item checkbox">
            <label>
              <input 
                type="checkbox" 
                v-model="mapSettings.showGrid"
              >
              显示网格
            </label>
          </div>
          <div class="setting-item checkbox">
            <label>
              <input 
                type="checkbox" 
                v-model="mapSettings.showLabels"
              >
              显示标签
            </label>
          </div>
          <div class="setting-item checkbox">
            <label>
              <input 
                type="checkbox" 
                v-model="mapSettings.showTraffic"
              >
              显示客流
            </label>
          </div>
        </div>
      </div>

      <div class="project-stats">
        <h3>项目统计</h3>
        <div class="stats-grid">
          <div class="stat-item">
            <span class="stat-label">地铁线路</span>
            <span class="stat-value">{{ projectStats.totalLines }}</span>
            <span class="stat-unit">条</span>
          </div>
          <div class="stat-item">
            <span class="stat-label">车站总数</span>
            <span class="stat-value">{{ projectStats.totalStations }}</span>
            <span class="stat-unit">座</span>
          </div>
          <div class="stat-item">
            <span class="stat-label">线网长度</span>
            <span class="stat-value">{{ projectStats.totalLength }}</span>
            <span class="stat-unit">km</span>
          </div>
          <div class="stat-item">
            <span class="stat-label">日均客流</span>
            <span class="stat-value">{{ projectStats.dailyPassengers }}</span>
            <span class="stat-unit">人次</span>
          </div>
        </div>
      </div>

      <div class="quick-actions">
        <h3>快捷操作</h3>
        <div class="actions-grid">
          <button class="action-btn">
            <span class="action-icon">📤</span>
            生成报告
          </button>
          <button class="action-btn">
            <span class="action-icon">💾</span>
            导出数据
          </button>
          <button class="action-btn">
            <span class="action-icon">🔄</span>
            同步云端
          </button>
          <button class="action-btn">
            <span class="action-icon">🔍</span>
            查看历史
          </button>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.design-container {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 32px;
  min-height: calc(100vh - 72px);
  padding: 20px;
}

.main-workspace {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.map-section {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.map-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.project-info h2 {
  font-size: 24px;
  color: #0f172a;
  margin-bottom: 4px;
}

.last-modified {
  font-size: 14px;
  color: #666;
}

.map-controls {
  display: flex;
  gap: 12px;
}

.control-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: #f1f5f9;
  color: #0f172a;
  cursor: pointer;
  transition: all 0.3s;
}

.control-btn:hover {
  background: #e2e8f0;
}

.map-container {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
}

.map-canvas {
  aspect-ratio: 16/9;
  background: #f8fafc;
  position: relative;
}

.placeholder-grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: linear-gradient(#e2e8f0 1px, transparent 1px),
                    linear-gradient(90deg, #e2e8f0 1px, transparent 1px);
  background-size: 20px 20px;
}

.map-tools {
  position: absolute;
  left: 20px;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: white;
  padding: 8px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  transition: all 0.3s;
}

.tool-btn:hover,
.tool-btn.active {
  background: #f1f5f9;
}

.tool-icon {
  font-size: 20px;
}

.tool-name {
  color: #0f172a;
}

.line-manager {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.line-manager h3 {
  font-size: 18px;
  color: #0f172a;
  margin-bottom: 16px;
}

.lines-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.line-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
}

.line-color {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

.line-info {
  flex: 1;
}

.line-info h4 {
  font-size: 16px;
  color: #0f172a;
  margin-bottom: 4px;
}

.line-stats {
  display: flex;
  gap: 16px;
  font-size: 14px;
  color: #666;
}

.line-status {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
}

.line-status.active {
  background: #dcfce7;
  color: #166534;
}

.line-status.construction {
  background: #fff7ed;
  color: #9a3412;
}

.line-actions {
  display: flex;
  gap: 8px;
}

.line-actions .action-btn {
  padding: 4px 12px;
  border: none;
  border-radius: 6px;
  background: #f1f5f9;
  color: #0f172a;
  cursor: pointer;
  transition: all 0.3s;
}

.line-actions .action-btn:hover {
  background: #e2e8f0;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.map-settings,
.project-stats,
.quick-actions {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.map-settings h3,
.project-stats h3,
.quick-actions h3 {
  font-size: 18px;
  color: #0f172a;
  margin-bottom: 16px;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setting-item label {
  color: #666;
  flex: 1;
}

.setting-item input[type="range"] {
  flex: 2;
}

.setting-value {
  min-width: 48px;
  text-align: right;
  color: #0f172a;
}

.setting-item.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.stat-item {
  background: #f8fafc;
  padding: 16px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-label {
  font-size: 14px;
  color: #666;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: #0f172a;
}

.stat-unit {
  font-size: 12px;
  color: #666;
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px;
  background: #f8fafc;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
}

.action-btn:hover {
  background: #f1f5f9;
  transform: translateY(-2px);
}

.action-icon {
  font-size: 24px;
}

@media (min-width: 1920px) {
  .design-container {
    grid-template-columns: 1fr 400px;
  }
}
</style> 